package huas.ant.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import huas.ant.common.PageResult;
import huas.ant.entity.Coach;
import huas.ant.entity.Equipment;
import huas.ant.mapper.CoachMapper;
import huas.ant.service.CoachService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;

@Service
public class CoachServiceImpl implements CoachService {
    @Autowired
    private CoachMapper coachMapper;
    /**
     * 分页列表查询
     */
    @Override
    public PageResult page(Integer page, Integer pageSize) {
        PageHelper.startPage(page,pageSize);

        Page<Coach> p = coachMapper.page();

        return new PageResult(p.getTotal(),p.getResult());
    }
    /**
     * 添加教练
     */
    @Override
    public void insert(Coach coach) {
        coach.setEntryTime(LocalDate.now());
        coachMapper.insert(coach);
    }
    /**
     * 根据教练ID查询设备信息
     */
    @Override
    public Coach findById(Integer id) {
        Coach coach = coachMapper.findById(id);
        return coach;
    }
    /**
     * 修改教练信息
     */
    @Override
    public void update(Coach coach) {
        coachMapper.update(coach);
    }
    /**
     * 删除教练信息
     */
    @Override
    public void delete(Integer id) {
        coachMapper.delete(id);
    }
}
